﻿CREATE FUNCTION dbo.VerTree_TextAttr
	(
	@ID varchar(10),
	@Lable varchar(512),
	@Checked bit,
	@CoolTip varchar(4000),
	@MsgsNumber varchar(1),
	@IsSmart bit,
	@IsCustom bit,
	@Owner sysname
	)
RETURNS varchar(8000)
AS
BEGIN
DECLARE @Class varchar(128),@Style varchar(512),
				@IsChecked sysname,@Out varchar(8000),
				@Img varchar(1024),@ImgUrl varchar(256),
				@CheckBox varchar(256),@Color varchar(50)

SET @Lable = REPLACE(ISNULL(NULLIF(RTRIM(LTRIM(@Lable)),''),'No Label'),'''','')
SELECT @Class = 'Checked',@Style = ''
IF @Checked = 0 SET @Class = 'un'+@Class
IF @IsSmart = 1 SET @Style = ';FONT-STYLE: italic'
IF @Checked = 1 SET @Style = @Style+';color:darkgreen' ELSE SET @Style = @Style+';color:darkred'
IF ISNULL(@CoolTip,@Lable) = @Lable BEGIN
	SET @CoolTip = @Lable
	SET @Lable = SUBSTRING(@Lable,1,25) 
END

SET @CoolTip = @ID+'|'+@CoolTip+ISNULL('(<B style="color:navy">'+@Owner+'</B>)','')

SET @Out = --@ID+
'
<SPAN id="spnNodeLable" oncontextmenu="return showNodeMenu()"	onmouseover1="try{toolTip.element=this}catch(e){}"
	coolTip='''+ISNULL(NULLIF(@CoolTip,''),@Lable)+'''
	style="'+@Style+'"
	onclick="showPages(this)">'+@Lable+'</SPAN>';
--	style="color:expression(this.parentElement.all.chkBox.checked?''darkgreen'':''darkred'');'+@Style+'"

IF @IsCustom = 1 SET @Out = '<SPAN> &bull;</SPAN>' + @Out

SET @ImgUrl = dbo.VerTree_Img_Envelop(@MsgsNumber)

SET @Img = 
'<IMG src="'+@ImgUrl+'" onclick="messageToBroker(this)"	oncontextmenu="return false"	onmouseover="return imageOver(this)">'

--SET @Img = @Img + '<IMG id="imgMsgs" style="margin-left:2px;margin-right:-2px" src="images/MsgTo'+@MsgsNumber+'.gif">'

SET @CheckBox ='
<INPUT id="chkBox'+@ID+'" type="checkbox"' + (CASE @Checked WHEN 1 THEN ' CHECKED ' ELSE '' END) + '	onclick="return checkBox(this)">'

RETURN @CheckBox + @Img + @Out

END




